import request from '@/utils/request';
import qs from 'qs';

// 物料列表查询（分页）
export function queryPage(params) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/queryPage',
    method: 'get',
    params
  });
}
// 物料列表查询
export function query(params) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/query',
    method: 'get',
    params
  });
}

// 导出数据 /oper/bom/download
export function download(url, params) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/download?' + qs.stringify(params, { indices: false }),
    method: 'get',
    responseType: 'blob'
  });
}

// 新增物料 /oper/bom/create
export function createBom(data) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/create',
    method: 'post',
    data
  });
}

// 修改物料 /oper/bom/update
export function updateBom(data) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/update',
    method: 'put',
    data
  });
}

// 删除物料 /oper/bom/delete
export function deleteBom(data) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/delete',
    method: 'delete',
    data
  });
}

// 修改物料状态 /oper/bom/stat
export function statBom(data) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/stat',
    method: 'delete',
    data
  });
}

// 增加物料库存 /oper/bom/addRemaining
export function addRemaining(data) {
  return request({
    url: process.env.VUE_APP_PRODUCT_API + '/oper/bom/addRemaining',
    method: 'delete',
    data
  });
}
